package com.greydawn.MementoPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: zhongwr
 * @Create: 2021/12/19 14:46
 * @Version 1.0
 * @Description: 状态管理类
 */
public class MementoManager {

    private List<Memento> mementoList = new ArrayList<Memento>();

    public void addMemento(Memento memento) {
        this.mementoList.add(memento);
    }

    public Memento getByIndex(int index) {
        return this.mementoList.get(index);
    }

    public void showMementoList() {
        for (int i = 0; i < this.mementoList.size(); i++) {
            System.out.println("存档：" + i + " 生命值：" + this.mementoList.get(i).getLifeValue());
        }
    }

}
